|
|
|
|
|
|
|
A conventional URL (the first line) represents only a single static Web page. On the other hand, one Active Server Page (the second line) can produce many different Web pages in a user's browser, all from a single URL. |
|
|
|
|
|
|
|
|
Think about how browsing works: through request-and-response communication between the browser and the Internet server. No matter what the Web server does, the end result is that a stream of HTML is returned to the browser in response to a request. When that request is for a standard .HTM file, it simply reads the file from the disk drive and passes it back to the browser. However, when the Internet server processes an .ASP file, it executes any embedded code during the process. This embedded script code can take different actions on the server, including generate the HTML that is returned to the browser. |
|
|
|
|
|
|
|
|
For example, suppose you want to create a Web page that displays the time of day when it is requested. The time of day is dynamic and cannot easily be placed in a standard static HTML page. However, you can do this easily with an Active Server Page, such as the one shown in Listing 31.1. |
|
|
|
|
|
|
|
|
Listing 31.1 ASPDEMO.ZIPA Simple Active Server Page Displays the Date and Time |
|
|
|
|
|
|
|
|
<HTML>
<BODY>
The Current date and time is
<%
Dim sTime
sTime = Now
Response.Write(sTime)
%>
</BODY>
</HTML> |
|
|
|
|
|
|
|
|
This ASP file in Listing 31.1 displays the current date and time. It contains a mixture of standard HTML and VBScript code. If you access the ASP file on your Web server, each time you press the browser's Refresh button, the server will execute the VBScript code, updating the date and time. However, if a user chooses to view the source in his browser, he will only see the resulting HTML: |
|
|
|
|
|
|
|
|
<HTML>
<BODY>
The Current date and time is
7/5/1998 12:30:00
</BODY>
</HTML> |
|
|
|
|
|